package cn.iocoder.yudao.module.resource.dal.mysql.resource;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.resource.dal.dataobject.resource.ResourceDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.resource.controller.admin.resource.vo.*;

/**
 * 资源管理 - 视频 音频 字幕等 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface ResourceMapper extends BaseMapperX<ResourceDO> {

    default PageResult<ResourceDO> selectPage(ResourcePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ResourceDO>()
                .eqIfPresent(ResourceDO::getResType, reqVO.getResType())
                .eqIfPresent(ResourceDO::getResCode, reqVO.getResCode())
                .likeIfPresent(ResourceDO::getResName, reqVO.getResName())
                .eqIfPresent(ResourceDO::getResContent, reqVO.getResContent())
                .betweenIfPresent(ResourceDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ResourceDO::getId));
    }

    default List<ResourceDO> selectList(ResourceExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<ResourceDO>()
                .eqIfPresent(ResourceDO::getResType, reqVO.getResType())
                .eqIfPresent(ResourceDO::getResCode, reqVO.getResCode())
                .likeIfPresent(ResourceDO::getResName, reqVO.getResName())
                .eqIfPresent(ResourceDO::getResContent, reqVO.getResContent())
                .betweenIfPresent(ResourceDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ResourceDO::getId));
    }

}
